﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ProjetoComperio.BusinessLogicLayer;
using ProjetoComperio.Framework.Web.Security;
using Controller = System.Web.Mvc.Controller;
using ProjetoComperio.DataLayer.Entities;

namespace ProjetoComperio.Presentation.Web.Controllers
{
    [RequiresAuthentication]
    public class SearchController : Controller
    {
        [HttpPost]
        public ActionResult Search(FormCollection formCollection)
        {
            var searchBLL = new SearchBLL();

            ViewData["ContributionType"] = formCollection["ContributionType"];
            ViewData["SearchResults"] = searchBLL.SearchContribution(formCollection["SearchText"], formCollection["ContributionType"]);

            return View("Search");
        }

        [HttpGet]
        public ActionResult Search()
        {
            var searchBLL = new SearchBLL();

            ViewData["SearchResults"] = new ContributionBLL().RetrieveAllContributions().OfType<Project>();

            return View("Search");
        }
    }
}
